<template>
  <div>
    <router-link to="/Order">我的订单</router-link>


      <table border="1" cellspacing="0">
        <colgroup span="4" width="200px"></colgroup>
        <tr>
          <td>图片</td>
          <td>标题</td>
          <td>价格</td>
          <td>操作</td>
        </tr>
        <tr v-for="i in goods" :key="i.id">
          <td>
            <img :src="baseUrl+i.img">
          </td>
          <td>{{i.title}}</td>
          <td>{{i.price1}}</td>
          <td>
            <button @click="buy(i.id)">立即购买</button>
          </td>
        </tr>
      </table>
  </div>
</template>

<script>
export default {
  data(){
    return{
      goods:[],
      baseUrl:'http://127.0.0.1:8000/static/',
    }
  },
  mounted(){
    let uid=localStorage.getItem('uid')
    this.axios({
      url:'http://127.0.0.1:8000/app01/goods/',
      method:'get',
      params:{uid:uid}
    }).then(res=>{
      this.goods=res.data;
    })
  },
  methods:{
    buy:function(goodid){
      this.$router.push({
        path:'/buy',
        query:{goodid:goodid}
      })
    }
  }
}
</script>

<style>

</style>
